﻿using QwLib;
using SCADA.Drive;
using SIE.SCADA.ZemtDemo.Machines;
using SysManage.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIE.SCADA.ZemtDemo
{
    class Env
    {
        public static AutoSaveParameterItem<string> ConnectStr;

        public static User CurUser;
        public static Dictionary<string, BaseProtocol> Devices { get; internal set; }
                = new Dictionary<string, BaseProtocol>();

        public static Dictionary<string, BaseMachine> Machines { get; internal set; }
                = new Dictionary<string, BaseMachine>();

        public static string DeviceCfgFile { get; set; } = AppDomain.CurrentDomain.BaseDirectory + "DeviceCfg.xml";

        #region RabbitMQ配置
        public static AutoSaveParameterItem<string> MQ_HostName;

        public static AutoSaveParameterItem<string> MQ_Port;

        public static AutoSaveParameterItem<string> MQ_UserName;

        public static AutoSaveParameterItem<string> MQ_Password;

        public static AutoSaveParameterItem<string> MQ_VirtualHost;

        public static AutoSaveParameterItem<bool> IS_MesClient;
        #endregion

        public static AutoSaveParameterItem<string> LineName;

        public static AutoSaveParameterItem<string> LineGroupName;

        public static AutoSaveParameterItem<string> AutoGet; //自动获取工单的间隔，小时

        public static AutoSaveParameterItem<int> MatcfgOvertime;

        public static AutoSaveParameterItem<string> DefaultUserName; 

        public static AutoSaveParameterItem<string> ProcessName;

        static Env()
        {
            XmlUserConfig.Create();
            ParameterInit();
        }

        static void ParameterInit()
        {
            MQ_HostName = new AutoSaveParameterItem<string>($"App.{nameof(MQ_HostName)}", "192.168.17.226")
            {
                DisplayName = "MQ服务器地址",
            };

            MQ_Port = new AutoSaveParameterItem<string>($"App.{nameof(MQ_Port)}", "5672")
            {
                DisplayName = "端口",
            };

            MQ_UserName = new AutoSaveParameterItem<string>($"App.{nameof(MQ_UserName)}", "smdc")
            {
                DisplayName = "帐户",
            };

            MQ_Password = new AutoSaveParameterItem<string>($"App.{nameof(MQ_Password)}", "123456")
            {
                DisplayName = "密码",
            };

            MQ_VirtualHost = new AutoSaveParameterItem<string>($"App.{nameof(MQ_VirtualHost)}", "/")
            {
                DisplayName = "虚拟主机",
            };

            LineName = new AutoSaveParameterItem<string>($"App.{nameof(LineName)}", "00000")
            {
                DisplayName = "线体名称",
            };
            LineGroupName = new AutoSaveParameterItem<string>($"App.{nameof(LineGroupName)}", "00000")
            {
                DisplayName = "线体组名称",
            };

            AutoGet = new AutoSaveParameterItem<string>($"App.{nameof(AutoGet)}", "6")
            {
                DisplayName = "自动获取时间",
            };

            MatcfgOvertime = new AutoSaveParameterItem<int>($"App.{nameof(MatcfgOvertime)}", 5)
            {
                DisplayName = "获取配置超时",
            };

            ProcessName = new AutoSaveParameterItem<string>($"App.{nameof(ProcessName)}", "10")
            {
                DisplayName = "工序名",
            };

            ConnectStr = new AutoSaveParameterItem<string>($"App.{nameof(ConnectStr)}", "PORT=5432;DATABASE=TJTK;HOST=localhost;PASSWORD=Mm123456;USER ID=postgres")
            {
                DisplayName = "数据库连接字符串",
            };
        }
    }
}
